home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1985 June
/
Ahoy_Magazine_85-06_1985_Double_L.d64
/
one voice player
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
5KB
|
199 lines
1 rem one voice player (fast)
2 rem plays "mexican hat dance"
3 rem
5 print"[147]":poke53280,0:poke53281,6
7 print:print" one voice player"
8 print:print" mexican hat dance..."
10 gosub 9000:goto 120
60 for n=1 to len(md$(ph))
61 d%=val(mid$(md$(ph),n,1))
64 poke gr,ug%:rem normal notes; delete pokes for legato
65 for i=0 to 1:poke fr(i),pi%(asc(mid$(me$(ph),n,1)),i):next
66 poke gr,g%
67 for i=0 to du%(val(mid$(md$(ph),n,1))):next
68 rem poke gr,ug%:rem staccato notes
69 next:ph=ph+1:if ph>es% then ph=0
70 poke gr,ug:return
100 gosub 60
110 if peek(653)>0 then end
120 print "phrase "ph
190 goto 100
8997 rem
8998 rem set up sound shape
8999 rem
9000 dim mv$(23),md$(23),me$(23),fr(1)
9001 dim du%(9),pi%(168,1)
9007 rem
9008 rem attack
9009 rem number from 0 to 15; lower number=sharper attack
9010 ak%=0
9015 ak%=ak%*16
9017 rem
9018 rem decay
9019 rem number from 0 to 15; lower number=faster decline
9020 dy%=5
9027 rem
9028 rem sustain
9029 rem number from 0 to 15; lower number=softer volume during sustain
9030 sn%=1
9035 sn%=sn%*16
9037 rem
9038 rem release
9039 rem number from 0 to 15; lower number=faster drop to silence at end
9040 re%=0
9047 rem
9048 rem set sound addresses
9049 rem
9050 fr(0)=54272
9055 fr(1)=1+fr(0):gr=fr(0)+4:ad=gr+1
9057 rem
9058 rem poke adsr envelope
9059 rem
9060 poke ad,at% or dy%
9065 poke ad+1,sn% or re%
9066 rem
9067 rem set up gate
9068 rem waveforms (add values):
9069 rem triangle on=16; sawtooth on=32; pulse on=64 (set width!); noise on=128
9070 wf%=32
9075 g%=1 or wf%:ug%=g% and 254
9077 rem
9078 rem set pulse width
9079 rem low byte, high byte
9080 poke gr-2,200:poke gr-1,3
9096 rem
9097 rem set up pitch array
9098 rem each note, in all its octaves
9099 rem c
9100 x%=3:gosub 9190
9101 data 12,1,24,2,48,4,97,8,195,16,135,33,15,67,30,134
9102 rem d
9103 x%=4:gosub 9190
9104 data 45,1,90,2,180,4,104,9,209,18,162,37,69,75,139,150
9105 rem e (f-flat)
9106 x%=5:gosub 9190:y%=13:gosub 9195
9107 data 81,1,163,2,71,5,143,10,31,21,62,42,125,84,250,168
9108 rem f (e-sharp)
9109 x%=6:gosub 9190:y%=19:gosub 9195
9110 data 102,1,204,2,152,5,48,11,96,22,193,44,131,89,6,179
9111 rem g
9112 x%=7:gosub 9190
9113 data 145,1,35,3,71,6,143,12,30,25,60,50,121,100,243,200
9114 rem a
9115 x%=1:gosub 9190
9116 data 195,1,134,3,12,7,24,14,49,28,99,56,199,112,143,225
9117 rem b
9118 x%=2:gosub 9190
9119 data 250,1,244,3,233,7,210,15,165,31,75,63,151,126,46,253
9120 rem d-flat (c-sharp)
9121 x%=11:gosub 9190:y%=17:gosub 9195
9122 data 28,1,56,2,112,4,225,8,195,17,134,35,12,71,24,142
9123 rem e-flat (d-sharp)
9124 x%=12:gosub 9190:y%=18:gosub 9195
9125 data 62,1,125,2,251,4,247,9,239,19,223,39,191,79,126,159
9126 rem g-flat (f-sharp)
9127 x%=14:gosub 9190:y%=20:gosub 9195
9128 data 123,1,246,2,237,5,218,11,181,23,107,47,214,94,172,189
9129 rem a-flat (g-sharp)
9130 x%=8:gosub 9190:y%=21:gosub 9195
9131 data 169,1,83,3,167,6,78,13,156,26,57,53,115,106,230,212
9132 rem b-flat (a-sharp)
9133 x%=9:gosub 9190:y%=15:gosub 9195
9134 data 221,1,187,3,119,7,239,14,223,29,190,59,124,119,248,238
9135 rem c-flat
9136 x%=10:gosub 9190
9137 data 4,1,250,1,244,3,233,7,210,15,165,31,75,63,151,126
9138 rem b-sharp
9139 x%=16:gosub 9190
9140 data 24,2,48,4,97,8,195,16,135,33,15,67,30,134,255,255
9150 for i=0 to 147 step 21:pi%(i,0)=0:pi%(i,1)=0:next
9185 goto 9200
9189 rem read pitches
9190 for i=0 to 147 step 21:read pi%(i+x%,0),pi%(i+x%,1):next:return
9194 rem identical pitches
9195 for i=0 to 147 step 21:pi%(i+y%,0)=pi%(i+x%,0):pi%(i+y%,1)=pi%(i+x%,1)
9196 next:return
9197 rem
9198 rem set up durations
9199 rem
9200 for i=0 to 9:read du%(i):next
9205 data 16,32,48,64,96,128,160,192,256,320
9296 rem
9297 rem set filter and volume
9298 rem filter frequency
9299 rem low byte (0-7) x%; high byte (0-255) y%
9300 x%=0:y%=100
9305 poke 54293,x%:poke 54294,y%
9308 rem filter on?
9309 rem voice 1 on=1
9310 x%=0
9318 rem filter resonance
9319 rem peak volume (0=low, 15=high)
9320 y%=14
9325 y%=y%*16:poke 54295,x% or y%
9328 rem select filter type
9329 rem low-pass=1;band-pass=2;high-pass=4;lo-band=3;hi-band=6;all=7
9330 x%=1
9335 x%=x%*16
9337 rem
9338 rem select overall volume
9339 rem 15=high, 0=low
9340 y%=15
9345 poke 54296,x% or y%
9496 rem
9497 rem set melody
9498 rem
9509 rem how many phrases? (minus one)
9510 es%=5
9514 rem
9515 rem melody strings
9516 rem
9517 rem each phrase has only one du%(ph%) string, no matter how many voices
9518 rem each phrase has one me$(ph%,vc%) & one mv$(ph%,vc%) string per voice
9519 rem phrase 0
9520 md$(0)="00000000040000000004"
9521 me$(0)="g[198]ge[196]ecbcgefgabcdefd"
9522 mv$(0)="6 565 6 "
9529 rem phrase 1
9530 md$(1)="0000000004000000006"
9531 me$(1)="fefd[195]db[193]bgg[198]gagfedc"
9532 mv$(1)="6 5 6 "
9539 rem phrase 2
9540 md$(2)="000000015000000015"
9541 me$(2)="gc@gc@gc@gcdcb@cd@"
9542 mv$(2)="34 34 34 34 3 4 "
9549 rem phrase 3
9550 md$(3)="000000015000000015"
9551 me$(3)="gb@gb@gb@gbcba@bc@"
9552 mv$(3)="3 43 4 "
9559 rem phrase 4
9560 md$(4)="11111111151111111115"
9561 me$(4)="dddaaacccbdddaaacccb"
9562 mv$(4)="5 4 5 45 4 5 4"
9569 rem phrase 5
9570 md$(5)="1111111115111111118"
9571 me$(5)="dddaaacccbd[195]dedcbag"
9572 mv$(5)="5 4 5 45 4 "
9898 rem convert strings to usable form
9899 rem
9900 for ph=0 to es%
9905 a$=me$(ph):me$(ph)=""
9910 for i=1 to len(a$)
9920 x%=asc(mid$(a$,i,1))
9930 if x%<72 then x%=x%-64:if x%<0 then x%=0
9931 if x%>192and x%<200 then x%=x%-178
9932 if x%=176 then x%=8
9933 if x%=191 then x%=9
9934 if x%=188 then x%=10
9935 if x%=172 then x%=11
9936 if x%=177 then x%=12
9937 if x%=187 then x%=13
9938 if x%=165 then x%=14
9939 if x%>21 then x%=0
9940 v$=mid$(mv$(ph),i,1):if v$<>" " then y%=21*val(v$)
9950 x%=x%+y%
9970 me$(ph)=me$(ph)+chr$(x%)
9975 next:next
9980 ph=0
9990 return